<template>
    <div class="navigationOfRepo">
      <tab>
        <tab-item class="navigationItem" :selected="flagOfItem==='report'?true:false" @on-item-click="reportFun">每日总结</tab-item>
        <tab-item class="navigationItem" :selected="flagOfItem==='schedule'?true:false" @on-item-click="toSchedule">任务&汇报</tab-item>
        <tab-item class="navigationItem" :selected="flagOfItem==='group'?true:false" @on-item-click="groupFun">群组管理</tab-item>
        <tab-item class="navigationItem" :selected="flagOfItem==='information'?true:false" @on-item-click="InfoManagerFun">个人中心</tab-item>
      </tab>
    </div>
</template>

<script>
import {Tab, TabItem } from 'vux'
import {mapState} from 'Vuex'

export default {
  props: {
    flagOfItem: {type: String}
  },
  data () {
    return {

    }
  },
  components: {
    Tab,
    TabItem
  },
  mounted () {
    // this.onBackCloseWindow()
  },
  computed: {
    ...mapState({
      userInfo: state => state.user.userInfo,
      userType: state => state.user.userType
    })
  },
  methods: {
    pushHistory () {
      var state = {
        title: 'title',
        url: this.$route.path
      }
      console.log('pushHistory:' + this.$route.path)
      window.history.replaceState(state, 'title', this.$route.path)
    },
    onBackCloseWindow () {
      this.pushHistory()
      window.addEventListener('popstate', closePage.bind(this.path), false)
      function closePage (path) {
        console.log(path)
        console.log(path.state)
        console.log(window.history)
        if (path.state === null) {
          WeixinJSBridge.call('closeWindow')
        }
      }
    },
    reportFun () {
      this.$router.replace({name:'U_view_all'})
    },
    toSchedule () {
        this.$router.replace({name: 'addReport'})
    },
    groupFun(){
      this.$router.replace({name: 'U_group'})
    },
    InfoManagerFun(){
      this.$router.replace({name: 'U_information'})
    },
  },
}
</script>
<style scoped>
.navigationOfRepo{
    position:fixed;
    bottom: 0px;
    width: 100%;
    z-index: 200;
}
.navigationOfRepo .navigationItem{
  background-color: #f9f9f9;
}
</style>
